/****************************************************************************
**                                                                         **
**                       PSSDK HNTcpManager module                         **
**            Copyright (c) 1997 - 2006 microOLAP Technologies LTD,        **
**                       Khalturin A.P., Naumov D.A.                       **
**                               Header File                               **
**                                                                         **
****************************************************************************/

//---------------------------------------------------------------------------
#ifndef __HN_PSSDK_TCPMANAGER_H__
#define __HN_PSSDK_TCPMANAGER_H__ 
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// Class CHNTcpManager
//---------------------------------------------------------------------------
class CHNTcpManager
{
private:
    HANDLE hTcpMgr;

public:
    //###########################################################################
    //    Create & Destroy
    //###########################################################################

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrCreate - Creates the HNTcpManager object.
    CHNTcpManager() { hTcpMgr = TcpMgrCreate(); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrDestroy - Destroys the HNTcpManager object.
    ~CHNTcpManager() { TcpMgrDestroy(hTcpMgr); }

public:
    //###########################################################################
    //    Additionals methods
    //###########################################################################
    BOOL     IsValid() { return (BOOL)(hTcpMgr != NULL); }
    operator HANDLE() { return hTcpMgr; }
    HANDLE   operator =(HANDLE hTcpMgr) { return this->hTcpMgr = hTcpMgr; }


public:
    //###########################################################################
    //    Methods of redirect
    //###########################################################################

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrGetCheckTcpSum - Returns the TCP packet checksum verification flag.
    BOOL Get_CheckTcpSum() 
    { return TcpMgrGetCheckTcpSum(hTcpMgr); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetCheckTcpSum - Sets the TCP packet checksum verification flag.
    BOOL Set_CheckTcpSum(BOOL CheckTcpSum) 
    { return TcpMgrSetCheckTcpSum(hTcpMgr,CheckTcpSum); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrGetInvaderMode - Returns the TCP sessions capturing mode flag.
    BOOL Get_InvaderMode() 
    { return TcpMgrGetInvaderMode(hTcpMgr); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetInvaderMode - Sets the TCP sessions capturing mode flag.
    BOOL Set_InvaderMode(BOOL InvaderMode) 
    { return TcpMgrSetInvaderMode(hTcpMgr,InvaderMode); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrGetMaxSessionsCount - Returns the maximum number of TCP sessions to be monitored at the same time.
    DWORD Get_MaxSessionsCount() 
    { return TcpMgrGetMaxSessionsCount(hTcpMgr); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetMaxSessionsCount - Sets the maximum number of TCP sessions to be monitored at the same time.
    DWORD Set_MaxSessionsCount(DWORD MaxSessionsCount) 
    { return TcpMgrSetMaxSessionsCount(hTcpMgr,MaxSessionsCount); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrGetSessionsCount - Returns the current number of TCP sessions are monitored.
    DWORD Get_SessionsCount() 
    { return TcpMgrGetSessionsCount(hTcpMgr); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrGetVirtualMode - Returns the virtual TCP sessions mode status flag.
    BOOL Get_VirtualMode() 
    { return TcpMgrGetVirtualMode(hTcpMgr); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetVirtualMode - Sets the virtual TCP sessions mode status flag.
    BOOL Set_VirtualMode(BOOL VirtualMode) 
    { return TcpMgrSetVirtualMode(hTcpMgr,VirtualMode); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrGetPendingPacketsCount - Returns the number of packets awaiting for processing.
    DWORD Get_PendingPacketsCount() 
    { return TcpMgrGetPendingPacketsCount(hTcpMgr); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrProcessPacket - Sends HNPacket object to the HNTcpManager component for further processing.
    VOID ProcessPacket(HANDLE hPkt) 
    { TcpMgrProcessPacket(hTcpMgr,hPkt); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrResetSessions - Deletes all HNTcpSession objects.
    VOID ResetSessions() 
    { TcpMgrResetSessions(hTcpMgr); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrResetOnTimeOut - Deletes obsolete HNTcpSession objects.
    VOID ResetOnTimeOut(DWORD TimeOut) 
    { TcpMgrResetOnTimeOut(hTcpMgr,TimeOut); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrCloseSession - Stops tracking of TCP session.
    VOID CloseSession(HANDLE hTcpSes) 
    { TcpMgrCloseSession(hTcpMgr,hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrDeleteSession - Deletes tracked TCP session.
    VOID DeleteSession(HANDLE hTcpSes) 
    { TcpMgrDeleteSession(hTcpMgr,hTcpSes); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetOnCreate - Sets the OnSessionCreate event.
    FARPROC Set_OnCreate(FARPROC pfOnCreate, DWORD_PTR Param) 
    { return TcpMgrSetOnCreate(hTcpMgr,pfOnCreate,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetOnConnect - Sets the OnSessionConnect event.
    FARPROC Set_OnConnect(FARPROC pfOnConnect, DWORD_PTR Param) 
    { return TcpMgrSetOnConnect(hTcpMgr,pfOnConnect,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetOnClient - Sets the OnClientData event.
    FARPROC Set_OnClient(FARPROC pfOnClient, DWORD_PTR Param) 
    { return TcpMgrSetOnClient(hTcpMgr,pfOnClient,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetOnServer - Sets the OnServerData event.
    FARPROC Set_OnServer(FARPROC pfOnServer, DWORD_PTR Param) 
    { return TcpMgrSetOnServer(hTcpMgr,pfOnServer,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetOnClose - Sets the OnSessionClose event.
    FARPROC Set_OnClose(FARPROC pfOnClose, DWORD_PTR Param) 
    { return TcpMgrSetOnClose(hTcpMgr,pfOnClose,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetOnDelete - Sets the OnSessionDelete event.
    FARPROC Set_OnDelete(FARPROC pfOnDelete, DWORD_PTR Param) 
    { return TcpMgrSetOnDelete(hTcpMgr,pfOnDelete,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - TcpMgrSetOnReturn - Sets the OnPacketReturn event.
    FARPROC Set_OnReturn(FARPROC pfOnReturn, DWORD_PTR Param) 
    { return TcpMgrSetOnReturn(hTcpMgr,pfOnReturn,Param); }

    //###########################################################################
    // Add in v2.4 
    //---------------------------------------------------------------------------
    // v2.4 - TcpMgrGetCheckIpSum - Returns the IP packet checksum verification flag.
    BOOL Get_CheckIpSum() 
    { return TcpMgrGetCheckIpSum(hTcpMgr); }

    //---------------------------------------------------------------------------
    // v2.4 - TcpMgrSetCheckIpSum - Sets the IP packet checksum verification flag.
    BOOL Set_CheckIpSum(BOOL CheckIpSum) 
    { return TcpMgrSetCheckIpSum(hTcpMgr,CheckIpSum); }
};


//---------------------------------------------------------------------------
#endif // __HN_PSSDK_TCPMANAGER_H__
//---------------------------------------------------------------------------
